"use client"; import { useEffect, useState } from "react"; import { useTranslations } from "next-intl"; import { fetchCommonQuestions, type FaqItem } from "@/lib/faq-api"; import { InlineLoading } from "@/components/ui/loading-state"; import { cn } from "@/lib/utils"; function Chevron({ className }: { className?: string }) { return ( ); } export function FaqClient() { const t = useTranslations("faq"); const [items, setItems] = useState(null); const [failed, setFailed] = useState(false); const [openIndex, setOpenIndex] = useState(null); useEffect(() => { let cancelled = false; void fetchCommonQuestions().then(({ items: next, failed: err }) => { if (cancelled) return; setItems(next); setFailed(err); }); return () => { cancelled = true; }; }, []); return ( {t("title")} {t("subtitle")} {items === null ? ( ) : failed ? ( {t("loadError")} ) : items.length === 0 ? ( {t("empty")} ) : ( {items.map((item, index) => { const open = openIndex === index; return ( setOpenIndex(open ? null : index)} > {item.question} {item.answer} ); })} )} ); }
{t("subtitle")}
{t("loadError")}
{t("empty")}
{item.answer}